import React, {useEffect} from 'react'
import { useSelector, useDispatch } from 'umi'
export default function index() {
  const num = useSelector(state => state.count.num);
  const cates = useSelector(state => state.count.cates);
  const dispatch = useDispatch();
  const addNum = () => {
    dispatch({
      type: 'count/add',
      num: 10
    })
  }
  useEffect(() => {
    dispatch({
      type: 'count/getCates',
      params: {
        page: 1,
        pageSize: 10
      }
    })
  }, [])
  return (
    <div>
      <h2>home页</h2>
      <button onClick = {
        addNum
      }>+</button>
      {num}

      <ul>
        {
          cates.map(cate => {
            return (
              <li key={cate.id}>
                <h5>{cate.name}</h5>
              </li>
            )
          })
        }
        <li></li>
      </ul>
    </div>
  )
}
